<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html">
    <body>
        <ui:composition template="../templates/default3.xhtml">        
            <ui:define name="content">
                <h:form id="addProductionSchedule" binding="#{productionScheduleManagerBean.loadUpdateProductionSchedule_up}">
                    <p:messages id="error"/>

                    <p:panel header="Initial production schedule  #{productionScheduleManagerBean.consolidatedMthSalesFcs[0].salesMonth}/#{productionScheduleManagerBean.consolidatedMthSalesFcs[0].salesYear}" id="productionSchedule" >


                        <p:dataTable id="productionSchedules" var="productionSchedule" value="#{productionScheduleManagerBean.productionSchedules}" 
                                     emptyMessage="No sales forecast updates found with given criteria."  update ="productionSchedules" paginator="true" rows="12"  
                                     paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}" >

                            <p:column  headerText="Line No." >  
                                <center><h:outputText value="#{productionSchedule.lineNumber}" /> </center> 
                            </p:column> 

                            <p:column  headerText="Month" >  
                                <center><h:outputText value="#{productionSchedule.operationMonth}" /> </center> 
                            </p:column> 
                            <p:column  headerText="Days available" >  
                                <center><h:outputText value="#{productionSchedule.totalNormalOperatingHours}" /> </center> 
                            </p:column> 
                            <p:column  headerText="Days utilized" >  
                                <center><h:outputText value="#{productionSchedule.totalNormalUtilizedOperatingHours}" /> </center> 
                            </p:column> 
                            <p:column  headerText="Utilization rate" >  
                                <center><h:outputText value="#{productionSchedule.utilizationRate}" /> </center> 
                            </p:column> 



                            <p:columnGroup type="footer">  
                                <p:row>  
                                    <p:column colspan="4" footerText="Average Utilization per month (%):" style="text-align:right"/>
                                    <p:column footerText="#{productionScheduleManagerBean.aveUtilizationRate}"/>

                                </p:row>   


                            </p:columnGroup>  


                        </p:dataTable>
                    </p:panel>

                    <p:panel header="Updates - sales forecast">

                        <p:dataTable id="salesForecasts" var="salesForecast" value="#{productionScheduleManagerBean.salesForecasts}"  update ="salesForecasts" >



                            <p:column  headerText="Product" >  
                                <center><h:outputText value="#{salesForecast.product.name}" /> </center> 
                            </p:column> 

                            <p:column  headerText="Quantity" >  
                                <center><h:outputText value="#{salesForecast.quantity}" /> </center> 
                            </p:column> 

                            <p:column  headerText="Remark" >  
                                <center><h:outputText value="#{salesForecast.remark}" /> </center> 
                            </p:column> 

                        </p:dataTable>


                    </p:panel>
                    
                    <p:panel header="Updates - outstandings">
                     <p:dataTable id="productionScheduleDay" var="productionScheduleDay" value="#{productionScheduleManagerBean.outstandingProductionScheduleDays}" 
                                     emptyMessage="No production outstandings found with given criteria." paginator="true" rows="5"  
                                     paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}">
                            <p:column headerText="Day">  
                                <center> <h:outputText value="#{productionScheduleDay.currentDay}"/> </center>
                            </p:column> 
                            <p:column headerText ="Product">  
                                <center> <h:outputText value="#{productionScheduleDay.product.name}"/> </center>
                            </p:column> 
                            <p:column headerText ="Quantity">  
                                <center> <h:outputText value="#{productionScheduleDay.quantity}"/> </center>
                            </p:column> 
                            <p:column headerText ="Hours taken">  
                                <center> <h:outputText value="#{productionScheduleDay.utilizedHours}"/> </center>
                            </p:column> 
                             <p:column headerText ="Type">  
                                <center> <h:outputText value="#{productionScheduleDay.type}"/> </center>
                            </p:column> 

                        </p:dataTable>

</p:panel>


                    <br/>
                    <br/>
                    <hr/>
                    <center><p:commandButton id="btnDone" value="Resolve" actionListener="#{productionScheduleManagerBean.updateProductionSchedule}" ajax="true" update="error " />
                    </center>
                    <p:ajaxStatus onstart="statusDialog.show();" onsuccess="statusDialog.hide();"/>  
                    <p:dialog modal="true" widgetVar="statusDialog" header="Please wait..."   
                              draggable="false" closable="false">  
                        <p:graphicImage value="../resources/images/ajaxloadingbar.gif" />  
                    </p:dialog>



                    <br/>




                </h:form>
            </ui:define>        
        </ui:composition>
    </body>
</html>
